<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup">
    <lv-form-item>
        <lv-form-label>
            {{'protection_restore_to_label' | i18n}}
        </lv-form-label>
        <lv-form-control>
            <lv-radio-group formControlName="restoreLocation">
                <lv-group [lvGutter]="'24px'">
                    <lv-radio [lvValue]="restoreLocationType.ORIGIN" [lvDisabled]="restoreToNewLocationOnly"
                        [lv-tooltip]="restoreToNewLocationOnly?('protection_origin_restore_disabled_label'| i18n):''">
                        {{ 'common_restore_to_origin_location_label' | i18n }}
                    </lv-radio>
                    <lv-radio [lvValue]="restoreLocationType.NEW" [lvDisabled]="isWorkspace">
                        {{ 'common_restore_to_new_location_label' | i18n }}
                    </lv-radio>
                </lv-group>
            </lv-radio-group>
        </lv-form-control>
    </lv-form-item>
    <ng-container *ngIf="formGroup.value.restoreLocation === restoreLocationType.ORIGIN">
        <ng-container *ngIf="!isHcsUser">
            <lv-form-item>
                <lv-form-label>
                    {{'common_origin_cloud_platform_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="originTargetCloudPlatform"
                        [lvOptions]="originTargetCloudPlatformOptions" lvValueKey="value" lvDisabled>
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>
                    {{'common_cloud_platform_tenant_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="originCloudPlatformTenant"
                        [lvOptions]="originCloudPlatformTenantOptions" lvValueKey="value" lvDisabled>
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>
                    {{'system_area_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="originRegions" [lvOptions]="originRegionsOptions" lvValueKey="value"
                        lvDisabled>
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>
                    {{'common_project_resource_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="originProjects" [lvOptions]="originProjectsOptions" lvValueKey="value"
                        lvDisabled>
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
        </ng-container>
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'common_cloud_server_label' | i18n}}
            </lv-form-label>
            <lv-form-control>
                <lv-select formControlName="originCloudHost" [lvOptions]="originCloudHostOptions" lvValueKey="value"
                    lvShowFilter lvFilterKey="label" lvFilterMode="contains" lvDisabled>
                </lv-select>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <ng-container *ngIf="formGroup.value.restoreLocation === restoreLocationType.NEW">
        <ng-container *ngIf="!isHcsUser">
            <lv-form-item>
                <lv-form-label lvRequired>
                    {{'common_target_cloud_platform_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="targetCloudPlatform" [lvOptions]="targetCloudPlatformOptions"
                        lvValueKey="value" lvShowFilter lvFilterKey="label" lvFilterMode="contains">
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label lvRequired>
                    {{'common_cloud_platform_tenant_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="cloudPlatformTenant" [lvOptions]="cloudPlatformTenantOptions"
                        lvValueKey="value" lvShowFilter lvFilterKey="label" lvFilterMode="contains">
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label lvRequired>
                    {{'system_area_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="regions" [lvOptions]="regionsOptions" lvValueKey="value" lvShowFilter
                        lvFilterKey="label" lvFilterMode="contains">
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label lvRequired>
                    {{'common_project_resource_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select formControlName="projects" [lvOptions]="projectsOptions" lvValueKey="value" lvShowFilter
                        lvFilterKey="label" lvFilterMode="contains">
                    </lv-select>
                </lv-form-control>
            </lv-form-item>
        </ng-container>
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'common_cloud_server_label' | i18n}}
            </lv-form-label>
            <lv-form-control>
                <lv-select formControlName="cloudHost" [lvOptions]="cloudHostOptions" lvValueKey="value" lvShowFilter
                    lvFilterKey="label" lvFilterMode="contains">
                </lv-select>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
</lv-form>

<div class="aui-gutter-column-xl"></div>

<lv-collapse [lvMultiExpansion]="'false'" lvType="simple">
    <lv-collapse-panel [lvTitle]="titleTpl" [lvExpanded]="false">
        <lv-form [formGroup]="formGroup" [lvLabelColon]="false" class="formGroup">
            <lv-form-item>
                <lv-form-label>
                    {{'protection_proxy_host_label' | i18n}}
                    <i lv-icon="aui-icon-help" [lv-tooltip]="'protection_hcs_proxy_server_tip_label' | i18n"
                        lvTooltipTheme="light" class="configform-constraint" lvColorState="true"></i>
                </lv-form-label>
                <lv-form-control>
                    <lv-select [lvOptions]="proxyOptions" formControlName="proxyHost" lvValueKey='value' lvShowCheckAll
                        lvShowFilter lvFilterKey="label" lvFilterMode="contains" lvMode="multiple"
                        [lvContentTemplate]="contentTpl"
                        lvPlaceholder="{{'protection_agent_placeholder_label' | i18n}}"></lv-select>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>{{'protection_auto_power_on_label' | i18n}}</lv-form-label>
                <lv-form-control>
                    <lv-switch formControlName="restoreAutoPowerOn"></lv-switch>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>{{'common_restore_before_copy_verify_label' | i18n}}
                    <i lv-icon="aui-icon-help" lv-tooltip="{{'protect_hcs_restore_before_copy_verify_label' | i18n}}"
                        lvTooltipPosition="rightTop" lvTooltipTheme="light" class="configform-constraint"
                        lvColorState='true'></i>
                </lv-form-label>
                <lv-form-control>
                    <lv-tooltip [lvContent]="copyVerifyDisableLabel|i18n"
                        *ngIf="verifyStatus === CopyDataVerifyStatus.noGenerate.value;else verifyStatusEnableTpl">
                        <lv-switch formControlName="copyVerify" [lvDisabled]="true"></lv-switch>
                    </lv-tooltip>
                    <ng-template #verifyStatusEnableTpl>
                        <lv-switch formControlName="copyVerify"></lv-switch>
                    </ng-template>

                </lv-form-control>
            </lv-form-item>
        </lv-form>
    </lv-collapse-panel>
</lv-collapse>

<ng-template #titleTpl>
    <lv-group lvGutter='8px'>
        <span class="custom-collapse-title-text">{{'common_advanced_label'|i18n}}</span>
    </lv-group>
</ng-template>
<ng-template #contentTpl let-item>
    <lv-group lvGutter="4px">
        <i lv-icon="{{
          item.linkStatus === dataMap.resource_LinkStatus_Special.normal.value ? 'aui-host-online' : 'aui-host-offline'
        }}"></i>
        <span>{{ item.label }}</span>
        <span class="aui-text-help-sm">
            {{item.extendInfo.scenario === dataMap.proxyHostType.builtin.value
            ? hostBuiltinLabel
            : hostExternalLabel
            }}</span>
    </lv-group>
</ng-template>